# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AndroidPublisher.V3.Model.InAppProduct do
  @moduledoc """
  An in-app product. The resource for InappproductsService.

  ## Attributes

  *   `defaultLanguage` (*type:* `String.t`, *default:* `nil`) - Default language of the localized data, as defined by BCP-47. e.g. "en-US".
  *   `defaultPrice` (*type:* `GoogleApi.AndroidPublisher.V3.Model.Price.t`, *default:* `nil`) - Default price. Cannot be zero, as in-app products are never free. Always in the developer's Checkout merchant currency.
  *   `gracePeriod` (*type:* `String.t`, *default:* `nil`) - Grace period of the subscription, specified in ISO 8601 format. Allows developers to give their subscribers a grace period when the payment for the new recurrence period is declined. Acceptable values are P0D (zero days), P3D (three days), P7D (seven days), P14D (14 days), and P30D (30 days).
  *   `listings` (*type:* `%{optional(String.t) => GoogleApi.AndroidPublisher.V3.Model.InAppProductListing.t}`, *default:* `nil`) - List of localized title and description data. Map key is the language of the localized data, as defined by BCP-47, e.g. "en-US".
  *   `managedProductTaxesAndComplianceSettings` (*type:* `GoogleApi.AndroidPublisher.V3.Model.ManagedProductTaxAndComplianceSettings.t`, *default:* `nil`) - Details about taxes and legal compliance. Only applicable to managed products.
  *   `packageName` (*type:* `String.t`, *default:* `nil`) - Package name of the parent app.
  *   `prices` (*type:* `%{optional(String.t) => GoogleApi.AndroidPublisher.V3.Model.Price.t}`, *default:* `nil`) - Prices per buyer region. None of these can be zero, as in-app products are never free. Map key is region code, as defined by ISO 3166-2.
  *   `purchaseType` (*type:* `String.t`, *default:* `nil`) - The type of the product, e.g. a recurring subscription.
  *   `sku` (*type:* `String.t`, *default:* `nil`) - Stock-keeping-unit (SKU) of the product, unique within an app.
  *   `status` (*type:* `String.t`, *default:* `nil`) - The status of the product, e.g. whether it's active.
  *   `subscriptionPeriod` (*type:* `String.t`, *default:* `nil`) - Subscription period, specified in ISO 8601 format. Acceptable values are P1W (one week), P1M (one month), P3M (three months), P6M (six months), and P1Y (one year).
  *   `subscriptionTaxesAndComplianceSettings` (*type:* `GoogleApi.AndroidPublisher.V3.Model.SubscriptionTaxAndComplianceSettings.t`, *default:* `nil`) - Details about taxes and legal compliance. Only applicable to subscription products.
  *   `trialPeriod` (*type:* `String.t`, *default:* `nil`) - Trial period, specified in ISO 8601 format. Acceptable values are anything between P7D (seven days) and P999D (999 days).
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :defaultLanguage => String.t() | nil,
          :defaultPrice => GoogleApi.AndroidPublisher.V3.Model.Price.t() | nil,
          :gracePeriod => String.t() | nil,
          :listings =>
            %{optional(String.t()) => GoogleApi.AndroidPublisher.V3.Model.InAppProductListing.t()}
            | nil,
          :managedProductTaxesAndComplianceSettings =>
            GoogleApi.AndroidPublisher.V3.Model.ManagedProductTaxAndComplianceSettings.t() | nil,
          :packageName => String.t() | nil,
          :prices =>
            %{optional(String.t()) => GoogleApi.AndroidPublisher.V3.Model.Price.t()} | nil,
          :purchaseType => String.t() | nil,
          :sku => String.t() | nil,
          :status => String.t() | nil,
          :subscriptionPeriod => String.t() | nil,
          :subscriptionTaxesAndComplianceSettings =>
            GoogleApi.AndroidPublisher.V3.Model.SubscriptionTaxAndComplianceSettings.t() | nil,
          :trialPeriod => String.t() | nil
        }

  field(:defaultLanguage)
  field(:defaultPrice, as: GoogleApi.AndroidPublisher.V3.Model.Price)
  field(:gracePeriod)
  field(:listings, as: GoogleApi.AndroidPublisher.V3.Model.InAppProductListing, type: :map)

  field(:managedProductTaxesAndComplianceSettings,
    as: GoogleApi.AndroidPublisher.V3.Model.ManagedProductTaxAndComplianceSettings
  )

  field(:packageName)
  field(:prices, as: GoogleApi.AndroidPublisher.V3.Model.Price, type: :map)
  field(:purchaseType)
  field(:sku)
  field(:status)
  field(:subscriptionPeriod)

  field(:subscriptionTaxesAndComplianceSettings,
    as: GoogleApi.AndroidPublisher.V3.Model.SubscriptionTaxAndComplianceSettings
  )

  field(:trialPeriod)
end

defimpl Poison.Decoder, for: GoogleApi.AndroidPublisher.V3.Model.InAppProduct do
  def decode(value, options) do
    GoogleApi.AndroidPublisher.V3.Model.InAppProduct.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AndroidPublisher.V3.Model.InAppProduct do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
